package com.wltjack.springboot.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wltjack.springboot.mapper.OrganizationMapper;
import com.wltjack.springboot.service.OrganizationService;
import com.wltjack.springboot.vo.OrganizationVO;
import com.wltjack.springboot.vo.enumtype.OrganizationType;

@Service
public class OrganizationServiceImpl implements OrganizationService {
	private transient final Logger log = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private OrganizationMapper organizationMapper;

	@Override
	public List<OrganizationVO> getAllOrganizations() {
		 List<OrganizationVO> allOrganizations = organizationMapper.getAllOrganizations();
		 if(allOrganizations !=null && allOrganizations.size()>0) {
			 for(OrganizationVO item:allOrganizations) {
				 if(item.getType() != null) {
					 item.setTypeName(OrganizationType.getNameById(item.getType()));
				 }
			 }
			 
		 }
		 return allOrganizations;
	}

}
